Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Actually retract clashing synthetic apply/unapply #5846

Merged
merged 1 commit into from
Apr 13, 2017

Conversation

adriaanm
Copy link
Contributor

Also make this whole retraction of apply/unapply in case of a
clashing user-defined member conditional on -Xsource:2.12.

It turns out, as explained by lrytz, that the retraction mechanism
was fragile because it relied on the order in which completers are run.
We now cover both the case that:

  • the completer was run, the IS_ERROR flag was set, and the
    symbol was unlinked from its scope before addSynthetics
    in typedStat iterates over the scope (since the symbol is
    already unlinked, the tree is not added, irrespective of its flags).
    For this case, we also remove the symbol from the synthetics in
    its unit (for cleanliness).

  • the completer is triggered during the iteration in addSynthetics,
    which needs the check for the IS_ERROR flag during the iteration.

Before, the completer just unlinked the symbol and set the IS_ERROR flag,
and I assumed the typer dropped a synthetic tree with a symbol with
that flag, because the tree was not shown in -Xprint output.
In reality, the completer just always happened to run before the
addSynthetics loop and unlinked the symbol from its scope in the
test cases I came up with (including the 2.11 community build).

Thankfully, the 2.12 community build caught my mistake, and lrytz provided
a good analysis and review.

Fix scala/bug#10261

@adriaanm adriaanm requested review from lrytz, densh and sjrd April 12, 2017 18:39
@adriaanm adriaanm added this to the 2.11.11 milestone Apr 12, 2017
Copy link
Member

@sjrd sjrd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also make this whole retraction of apply/unapply in case of a
clashing user-defined member conditional on -Xsource:2.12.

👍

@adriaanm
Copy link
Contributor Author

adriaanm commented Apr 12, 2017

(Forgot the flags files of course :-))

Copy link
Member

@lrytz lrytz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • also add [backport] to the commit msg

// (1) If we're already in the loop, set the IS_ERROR flag and trigger the condition
// `sym.initialize.hasFlag(IS_ERROR)` in typedStats::addSynthetics,
// (2) Or, if we are not yet in the addSynthetics loop (and we're not going to emit an error anyway),
// we unlink the symbol from its scope.
sym setFlag IS_ERROR
Copy link
Member

@lrytz lrytz Apr 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • add companionContext.unit.synthetics -= sym?

Also make this whole retraction of apply/unapply in case of a
clashing user-defined member conditional on `-Xsource:2.12`.

It turns out, as explained by lrytz, that the retraction mechanism
was fragile because it relied on the order in which completers are run.
We now cover both the case that:

  - the completer was run, the `IS_ERROR` flag was set, and the
  symbol was unlinked from its scope before `addSynthetics`
  in `typedStat` iterates over the scope (since the symbol is
  already unlinked, the tree is not added, irrespective of its flags).
  For this case, we also remove the symbol from the synthetics in
  its unit (for cleanliness).

  - the completer is triggered during the iteration in `addSynthetics`,
  which needs the check for the `IS_ERROR` flag during the iteration.

Before, the completer just unlinked the symbol and set the IS_ERROR flag,
and I assumed the typer dropped a synthetic tree with a symbol with
that flag, because the tree was not shown in -Xprint output.
In reality, the completer just always happened to run before the
addSynthetics loop and unlinked the symbol from its scope in the
test cases I came up with (including the 2.11 community build).

Thankfully, the 2.12 community build caught my mistake, and lrytz provided
a good analysis and review.

Fix scala/bug#10261
Copy link
Contributor

@densh densh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's much safer now under a flag. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-notes worth highlighting in next release notes
Projects
None yet
5 participants